<?php
/**
 * Created by PhpStorm.
 * User: kb130
 * Date: 2017/8/21
 * Time: 14:43
 */

namespace util\validate\rules;

/**
 * 验证值是否是可转换的boole类型
 * 1, 0, '1', '0', true, false 都认为是Boolean类型
 * Class Bool
 * @package validate\rules
 */
class Boolean extends BaseRule
{
    public function verify()
    {
        if (0 === $this->value || 0 === strcmp('0', $this->value) || 1 === $this->value || 0 === strcmp('1', $this->value)) {
            return true;
        }

        return is_bool($this->value);
    }
}